package p2pcdnsim.network;

public class TCPSegment implements Datagram {

	private static final long TCP_HEADER_SIZE = 16;
	
	private NetworkAddress sourceAddress;
	private int sourcedPort;
	private NetworkAddress destinationAddress;
	private int destinationPort;

	
	public NetworkAddress getSourceAddress() {
		return sourceAddress;
	}

	public int getSourcedPort() {
		return sourcedPort;
	}

	public NetworkAddress getDestinationAddress() {
		return destinationAddress;
	}

	public int getDestinationPort() {
		return destinationPort;
	}

	int SEQ_NUMBER;	//Sequence number of the TCP segment
	int ACK_NUMBER;	//ACK number of the TCP segment
	long WINDOW_SIZE;	//The send window advertised in this TCP segment.
	long LEN;	
	
	boolean ACK;
	boolean PSH;
	boolean RST;
	boolean SYN;
	boolean FIN;
	
	public TCPSegment(NetworkAddress localAddress, int localPort,
			NetworkAddress destinationAddress, int destinationPort) {
		this.sourceAddress = localAddress;
		this.sourcedPort = localPort;
		this.destinationAddress = destinationAddress;
		this.destinationPort = destinationPort;
		ACK = false;
		PSH = false;
		RST = false;
		SYN = false;
		FIN = false;
	}

	public void setSEQ(int seq) {
		this.SEQ_NUMBER = seq;
		
	}

	public void setSYN(boolean b) {
		this.SYN = true;
		
	}

	public void setLEN(long len) {
		this.LEN = len;
	}

	public long getSize() {
		return TCP_HEADER_SIZE+LEN;
	}

	public boolean getSYN() {
		return SYN;
	}

	public int getSEQ() {
		return SEQ_NUMBER;
	}

	public void setACK(int i) {
		this.ACK_NUMBER = i;
	}

	public void setACK(boolean ack) {
		this.ACK = ack;
	}

	public void setWND(long window) {
		this.WINDOW_SIZE = window;
	}

	public long getWND() {
		return WINDOW_SIZE;
	}

	public int getACK() {
		return ACK_NUMBER;
	}
	

}
